package com.example.consumerdemo.controller;

import com.example.consumerdemo.service.EchoFeignClientService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author kw
 * @program cloud-alibaba-demo
 * @description nacos 回调api
 * @create 2024 - 06 - 28 09:22
 **/
@RestController
public class IndexController {

    @Resource
    private RestTemplate restTemplate;

    @Resource
    private EchoFeignClientService echoFeignClientService;

    @GetMapping("/echo-rest/{str}")
    public String rest(@PathVariable String str) {
        return restTemplate.getForObject("http://provider-service/echo/" + str, String.class);
    }

    @GetMapping(value = "/echo-feign/{str}")
    public String feign(@PathVariable String str) {
        return echoFeignClientService.echo(str);
    }
}
